package com.huntech.data.controller;

import com.huntech.data.sevice.FileUploadService;
import com.huntech.data.util.ResponseCode;
import com.huntech.data.util.Result;
import com.huntech.data.util.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;

/**
 * excel数据处理
 *
 * @author： zq
 */
@RestController
@RequestMapping(value = "/excel/data")
@Api(tags = "数据处理")
public class TaskExcelDataController {

    @Autowired
    private FileUploadService fileUploadService;


    @PostMapping("/zip_read_test")
    @ApiOperation(value = "E文件转Excel文件")
    @ApiResponses({
            @ApiResponse(code = 200, message = "ok"),
    })
    public Result readZip(@RequestParam(name = "file") MultipartFile file , HttpServletResponse response) {
        try {
            fileUploadService.analysisExeclZip2(file ,response);
            return ResultUtil.success();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ResultUtil.error(ResponseCode.C_KNOWN_SERVER ,ResponseCode.M_KNOWN_SERVER);
    }


}
